<?php
/**
 * ExtTriggerFieldBase class file
 *
 * @author TrueSoftware B.V. (The Netherlands)
 * @link http://www.ext4yii.com
 * @copyright Copyright 2007-2010 TrueSoftwareB.V. all rights reserved.
 * @license http://www.ext4yii.com/license/
 *          EVALUATION VERSION - NOT FOR COMMERCIAL USE OR DISTRIBUTION.
 * @version 0.7.2
 */
abstract class ExtTriggerFieldBase extends ExtTextField
{
    public function parseNode(ExtHTMLParserNode $node,
            ExtASTWalker $astwalker)
    {
        parent::parseNode($node, $astwalker);
        $mitems = $node->findPropertyByName('menu');
        if(!is_null($mitems))
        {
            $this->setTriggerControl($node);
            $items=parent::parseNodeWidthTag($mitems,
                    $astwalker,
                    true,
                    null,
                    $this);
                $this->setJavaScriptConfig('menu', $items[0]);
                $action = 'function(){if(this.menu){this.onFocus();this.menu.show(this.el, "tl-bl?");}}';
                $this->setJavaScriptConfig('onTriggerClick',$action);
            $mitems->shiftUp();
        }
    }

    private function setTriggerControl($root)
    {
        foreach($root->children as $node)
        {
            $this->setTriggerControl($node);
            if(!is_null($node->extctl))
            {
                $node->extctl->setJavaScriptConfig('getTrigger','function(){return Ext.getCmp("'.$this->getId().'"); }');
            }
        }
    }
}
?>
